<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Quick reference guide</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__QuickRefPage.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Quick reference guide<div class="ingroups"><a class="el" href="group__DenseMatrixManipulation__chapter.html">Dense matrix and array manipulation</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<hr  />
<p><a href="#" class="top">top</a> </p>
<h1><a class="anchor" id="QuickRef_Headers"></a>
Modules and Header files</h1>
<p>The <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> library is divided in a Core module and several additional modules. Each module has a corresponding header file which has to be included in order to use the module. The <code>Dense</code> and <code><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a></code> header files are provided to conveniently gain access to several modules at once.</p>
<table class="manual">
<tr>
<th>Module</th><th>Header file</th><th>Contents </th></tr>
<tr>
<td><a class="el" href="group__Core__Module.html">Core </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Core&gt;</span></div>
</div><!-- fragment --></td><td><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> and <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> classes, basic linear algebra (including triangular and selfadjoint products), array manipulation </td></tr>
<tr class="alt">
<td><a class="el" href="group__Geometry__Module.html">Geometry </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Geometry&gt;</span></div>
</div><!-- fragment --></td><td><a class="el" href="classEigen_1_1Transform.html" title="Represents an homogeneous transformation in a N dimensional space.">Transform</a>, <a class="el" href="classEigen_1_1Translation.html" title="Represents a translation transformation.">Translation</a>, Scaling, <a class="el" href="classEigen_1_1Rotation2D.html" title="Represents a rotation/orientation in a 2 dimensional space.">Rotation2D</a> and 3D rotations (<a class="el" href="classEigen_1_1Quaternion.html" title="The quaternion class used to represent 3D orientations and rotations.">Quaternion</a>, <a class="el" href="classEigen_1_1AngleAxis.html" title="Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.">AngleAxis</a>) </td></tr>
<tr>
<td><a class="el" href="group__LU__Module.html">LU </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/LU&gt;</span></div>
</div><!-- fragment --></td><td><a class="el" href="classEigen_1_1Inverse.html" title="Expression of the inverse of another expression.">Inverse</a>, determinant, LU decompositions with solver (<a class="el" href="classEigen_1_1FullPivLU.html" title="LU decomposition of a matrix with complete pivoting, and related features.">FullPivLU</a>, <a class="el" href="classEigen_1_1PartialPivLU.html" title="LU decomposition of a matrix with partial pivoting, and related features.">PartialPivLU</a>) </td></tr>
<tr class="alt">
<td><a class="el" href="group__Cholesky__Module.html">Cholesky </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Cholesky&gt;</span></div>
</div><!-- fragment --></td><td><a class="el" href="classEigen_1_1LLT.html" title="Standard Cholesky decomposition (LL^T) of a matrix and associated features.">LLT</a> and <a class="el" href="classEigen_1_1LDLT.html" title="Robust Cholesky decomposition of a matrix with pivoting.">LDLT</a> Cholesky factorization with solver </td></tr>
<tr>
<td><a class="el" href="group__Householder__Module.html">Householder </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Householder&gt;</span></div>
</div><!-- fragment --></td><td>Householder transformations; this module is used by several linear algebra modules </td></tr>
<tr class="alt">
<td><a class="el" href="group__SVD__Module.html">SVD </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/SVD&gt;</span></div>
</div><!-- fragment --></td><td>SVD decompositions with least-squares solver (<a class="el" href="classEigen_1_1JacobiSVD.html" title="Two-sided Jacobi SVD decomposition of a rectangular matrix.">JacobiSVD</a>, <a class="el" href="classEigen_1_1BDCSVD.html" title="class Bidiagonal Divide and Conquer SVD">BDCSVD</a>) </td></tr>
<tr>
<td><a class="el" href="group__QR__Module.html">QR </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/QR&gt;</span></div>
</div><!-- fragment --></td><td>QR decomposition with solver (<a class="el" href="classEigen_1_1HouseholderQR.html" title="Householder QR decomposition of a matrix.">HouseholderQR</a>, <a class="el" href="classEigen_1_1ColPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with column-pivoting.">ColPivHouseholderQR</a>, <a class="el" href="classEigen_1_1FullPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with full pivoting.">FullPivHouseholderQR</a>) </td></tr>
<tr class="alt">
<td><a class="el" href="group__Eigenvalues__Module.html">Eigenvalues </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Eigenvalues&gt;</span></div>
</div><!-- fragment --></td><td>Eigenvalue, eigenvector decompositions (<a class="el" href="classEigen_1_1EigenSolver.html" title="Computes eigenvalues and eigenvectors of general matrices.">EigenSolver</a>, <a class="el" href="classEigen_1_1SelfAdjointEigenSolver.html" title="Computes eigenvalues and eigenvectors of selfadjoint matrices.">SelfAdjointEigenSolver</a>, <a class="el" href="classEigen_1_1ComplexEigenSolver.html" title="Computes eigenvalues and eigenvectors of general complex matrices.">ComplexEigenSolver</a>) </td></tr>
<tr>
<td><a class="el" href="group__Sparse__Module.html">Sparse </a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Sparse&gt;</span></div>
</div><!-- fragment --></td><td>Sparse matrix storage and related basic linear algebra (<a class="el" href="classEigen_1_1SparseMatrix.html" title="A versatible sparse matrix representation.">SparseMatrix</a>, <a class="el" href="classEigen_1_1SparseVector.html" title="a sparse vector class">SparseVector</a>) <br  />
 (see <a class="el" href="group__SparseQuickRefPage.html">Quick reference guide for sparse matrices</a> for details on sparse modules) </td></tr>
<tr class="alt">
<td></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
</div><!-- fragment --></td><td>Includes Core, Geometry, LU, Cholesky, SVD, QR, and Eigenvalues header files </td></tr>
<tr>
<td></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Eigen&gt;</span></div>
</div><!-- fragment --></td><td>Includes Dense and Sparse header files (the whole <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> library) </td></tr>
</table>
<p><a href="#" class="top">top</a> </p>
<h1><a class="anchor" id="QuickRef_Types"></a>
Array, matrix and vector types</h1>
<p><b>Recall:</b> <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> provides two kinds of dense objects: mathematical matrices and vectors which are both represented by the template class <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a>, and general 1D and 2D arrays represented by the template class <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>: </p><div class="fragment"><div class="line"><span class="keyword">typedef</span> Matrix&lt;Scalar, RowsAtCompileTime, ColsAtCompileTime, Options&gt; MyMatrixType;</div>
<div class="line"><span class="keyword">typedef</span> Array&lt;Scalar, RowsAtCompileTime, ColsAtCompileTime, Options&gt; MyArrayType;</div>
</div><!-- fragment --><ul>
<li><code>Scalar</code> is the scalar type of the coefficients (e.g., <code>float</code>, <code>double</code>, <code>bool</code>, <code>int</code>, etc.). </li>
<li><code>RowsAtCompileTime</code> and <code>ColsAtCompileTime</code> are the number of rows and columns of the matrix as known at compile-time or <code>Dynamic</code>. </li>
<li><code>Options</code> can be <code>ColMajor</code> or <code>RowMajor</code>, default is <code>ColMajor</code>. (see class <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> for more options)</li>
</ul>
<p>All combinations are allowed: you can have a matrix with a fixed number of rows and a dynamic number of columns, etc. The following are all valid: </p><div class="fragment"><div class="line">Matrix&lt;double, 6, Dynamic&gt;                  <span class="comment">// Dynamic number of columns (heap allocation)</span></div>
<div class="line">Matrix&lt;double, Dynamic, 2&gt;                  <span class="comment">// Dynamic number of rows (heap allocation)</span></div>
<div class="line">Matrix&lt;double, Dynamic, Dynamic, RowMajor&gt;  <span class="comment">// Fully dynamic, row major (heap allocation)</span></div>
<div class="line">Matrix&lt;double, 13, 3&gt;                       <span class="comment">// Fully fixed (usually allocated on stack)</span></div>
</div><!-- fragment --><p>In most cases, you can simply use one of the convenience typedefs for <a class="el" href="group__matrixtypedefs.html">matrices</a> and <a class="el" href="group__arraytypedefs.html">arrays</a>. Some examples: </p><table class="example">
<tr>
<th>Matrices</th><th>Arrays </th></tr>
<tr>
<td><div class="fragment"><div class="line">Matrix&lt;float,Dynamic,Dynamic&gt;   &lt;=&gt;   <a class="code" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a></div>
<div class="line">Matrix&lt;double,Dynamic,1&gt;        &lt;=&gt;   <a class="code" href="group__matrixtypedefs.html#ga8554c6170729f01c7572574837ecf618">VectorXd</a></div>
<div class="line">Matrix&lt;int,1,Dynamic&gt;           &lt;=&gt;   <a class="code" href="group__matrixtypedefs.html#ga75533fcdd7b769126a8a16cd8e342330">RowVectorXi</a></div>
<div class="line">Matrix&lt;float,3,3&gt;               &lt;=&gt;   <a class="code" href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Matrix3f</a></div>
<div class="line">Matrix&lt;float,4,1&gt;               &lt;=&gt;   <a class="code" href="group__matrixtypedefs.html#gae6a8e578d2848cc75f573c15a73bd9b4">Vector4f</a></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga276bae130c142e906ad8f47d24d11c1c"><div class="ttname"><a href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Eigen::Matrix3f</a></div><div class="ttdeci">Matrix&lt; float, 3, 3 &gt; Matrix3f</div><div class="ttdoc">3×3 matrix of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga731599f782380312960376c43450eb48"><div class="ttname"><a href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">Eigen::MatrixXf</a></div><div class="ttdeci">Matrix&lt; float, Dynamic, Dynamic &gt; MatrixXf</div><div class="ttdoc">Dynamic×Dynamic matrix of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga75533fcdd7b769126a8a16cd8e342330"><div class="ttname"><a href="group__matrixtypedefs.html#ga75533fcdd7b769126a8a16cd8e342330">Eigen::RowVectorXi</a></div><div class="ttdeci">Matrix&lt; int, 1, Dynamic &gt; RowVectorXi</div><div class="ttdoc">1×Dynamic vector of type int.</div><div class="ttdef"><b>Definition:</b> Matrix.h:499</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga8554c6170729f01c7572574837ecf618"><div class="ttname"><a href="group__matrixtypedefs.html#ga8554c6170729f01c7572574837ecf618">Eigen::VectorXd</a></div><div class="ttdeci">Matrix&lt; double, Dynamic, 1 &gt; VectorXd</div><div class="ttdoc">Dynamic×1 vector of type double.</div><div class="ttdef"><b>Definition:</b> Matrix.h:501</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_gae6a8e578d2848cc75f573c15a73bd9b4"><div class="ttname"><a href="group__matrixtypedefs.html#gae6a8e578d2848cc75f573c15a73bd9b4">Eigen::Vector4f</a></div><div class="ttdeci">Matrix&lt; float, 4, 1 &gt; Vector4f</div><div class="ttdoc">4×1 vector of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">Array&lt;float,Dynamic,Dynamic&gt;    &lt;=&gt;   ArrayXXf</div>
<div class="line">Array&lt;double,Dynamic,1&gt;         &lt;=&gt;   ArrayXd</div>
<div class="line">Array&lt;int,1,Dynamic&gt;            &lt;=&gt;   RowArrayXi</div>
<div class="line">Array&lt;float,3,3&gt;                &lt;=&gt;   Array33f</div>
<div class="line">Array&lt;float,4,1&gt;                &lt;=&gt;   Array4f</div>
</div><!-- fragment --> </td></tr>
</table>
<p>Conversion between the matrix and array worlds: </p><div class="fragment"><div class="line">Array44f a1, a2;</div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga3a5de8dfef28d29aed525611e15a37e3">Matrix4f</a> m1, m2;</div>
<div class="line">m1 = a1 * a2;                     <span class="comment">// coeffwise product, implicit conversion from array to matrix.</span></div>
<div class="line">a1 = m1 * m2;                     <span class="comment">// matrix product, implicit conversion from matrix to array.</span></div>
<div class="line">a2 = a1 + m1.array();             <span class="comment">// mixing array and matrix is forbidden</span></div>
<div class="line">m2 = a1.matrix() + m1;            <span class="comment">// and explicit conversion is required.</span></div>
<div class="line">ArrayWrapper&lt;Matrix4f&gt; m1a(m1);   <span class="comment">// m1a is an alias for m1.array(), they share the same coefficients</span></div>
<div class="line">MatrixWrapper&lt;Array44f&gt; a1m(a1);</div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga3a5de8dfef28d29aed525611e15a37e3"><div class="ttname"><a href="group__matrixtypedefs.html#ga3a5de8dfef28d29aed525611e15a37e3">Eigen::Matrix4f</a></div><div class="ttdeci">Matrix&lt; float, 4, 4 &gt; Matrix4f</div><div class="ttdoc">4×4 matrix of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
</div><!-- fragment --><p>In the rest of this document we will use the following symbols to emphasize the features which are specifics to a given kind of object: </p><ul>
<li><a class="anchor" id="matrixonly"></a><a href="#matrixonly" style="color:green;text-decoration: none;">*</a> linear algebra matrix and vector only </li>
<li><a class="anchor" id="arrayonly"></a><a href="#arrayonly" style="color:blue;text-decoration: none;">*</a> array objects only</li>
</ul>
<h2><a class="anchor" id="QuickRef_Basics"></a>
Basic matrix manipulation</h2>
<table class="manual">
<tr>
<th></th><th>1D objects</th><th>2D objects</th><th>Notes </th></tr>
<tr>
<td>Constructors </td><td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga9b2fcb53776a2829871f8a49009bef0b">Vector4d</a>  v4;</div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga4cbcafbd33875f185289e750e90d0188">Vector2f</a>  v1(x, y);</div>
<div class="line">Array3i   v2(x, y, z);</div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga9b2fcb53776a2829871f8a49009bef0b">Vector4d</a>  v3(x, y, z, w);</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga8028d921d43acd5605eabad41c254ef2">VectorXf</a>  v5; <span class="comment">// empty object</span></div>
<div class="line">ArrayXf   v6(size);</div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga4cbcafbd33875f185289e750e90d0188"><div class="ttname"><a href="group__matrixtypedefs.html#ga4cbcafbd33875f185289e750e90d0188">Eigen::Vector2f</a></div><div class="ttdeci">Matrix&lt; float, 2, 1 &gt; Vector2f</div><div class="ttdoc">2×1 vector of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga8028d921d43acd5605eabad41c254ef2"><div class="ttname"><a href="group__matrixtypedefs.html#ga8028d921d43acd5605eabad41c254ef2">Eigen::VectorXf</a></div><div class="ttdeci">Matrix&lt; float, Dynamic, 1 &gt; VectorXf</div><div class="ttdoc">Dynamic×1 vector of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga9b2fcb53776a2829871f8a49009bef0b"><div class="ttname"><a href="group__matrixtypedefs.html#ga9b2fcb53776a2829871f8a49009bef0b">Eigen::Vector4d</a></div><div class="ttdeci">Matrix&lt; double, 4, 1 &gt; Vector4d</div><div class="ttdoc">4×1 vector of type double.</div><div class="ttdef"><b>Definition:</b> Matrix.h:501</div></div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga3a5de8dfef28d29aed525611e15a37e3">Matrix4f</a>  m1;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a>  m5; <span class="comment">// empty object</span></div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a>  m6(nb_rows, nb_columns);</div>
</div><!-- fragment --></td><td class="note">By default, the coefficients <br  />
 are left uninitialized </td></tr>
<tr class="alt">
<td>Comma initializer </td><td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga5ec9ce2d8adbcd6888f3fbf2e1c095a4">Vector3f</a>  v1;     v1 &lt;&lt; x, y, z;</div>
<div class="line">ArrayXf   v2(4);  v2 &lt;&lt; 1, 2, 3, 4;</div>
<div class="ttc" id="agroup__matrixtypedefs_html_ga5ec9ce2d8adbcd6888f3fbf2e1c095a4"><div class="ttname"><a href="group__matrixtypedefs.html#ga5ec9ce2d8adbcd6888f3fbf2e1c095a4">Eigen::Vector3f</a></div><div class="ttdeci">Matrix&lt; float, 3, 1 &gt; Vector3f</div><div class="ttdoc">3×1 vector of type float.</div><div class="ttdef"><b>Definition:</b> Matrix.h:500</div></div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Matrix3f</a>  m1;   m1 &lt;&lt; 1, 2, 3,</div>
<div class="line">                      4, 5, 6,</div>
<div class="line">                      7, 8, 9;</div>
</div><!-- fragment --></td><td><p class="starttd"></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Comma initializer (bis) </td><td colspan="2"><div class="fragment"><div class="line"><span class="keywordtype">int</span> rows=5, cols=5;</div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a> m(rows,cols);</div>
<div class="line">m &lt;&lt; (<a class="code" href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Matrix3f</a>() &lt;&lt; 1, 2, 3, 4, 5, 6, 7, 8, 9).finished(),</div>
<div class="line">     <a class="code" href="classEigen_1_1DenseBase.html#a422ddeef58bedc7bddb1d4357688d761">MatrixXf::Zero</a>(3,cols-3),</div>
<div class="line">     <a class="code" href="classEigen_1_1DenseBase.html#a422ddeef58bedc7bddb1d4357688d761">MatrixXf::Zero</a>(rows-3,3),</div>
<div class="line">     <a class="code" href="classEigen_1_1MatrixBase.html#a98bb9a0f705c6dfde85b0bfff31bf88f">MatrixXf::Identity</a>(rows-3,cols-3);</div>
<div class="line">cout &lt;&lt; m;</div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_a422ddeef58bedc7bddb1d4357688d761"><div class="ttname"><a href="classEigen_1_1DenseBase.html#a422ddeef58bedc7bddb1d4357688d761">Eigen::DenseBase::Zero</a></div><div class="ttdeci">static const ConstantReturnType Zero()</div><div class="ttdef"><b>Definition:</b> CwiseNullaryOp.h:516</div></div>
<div class="ttc" id="aclassEigen_1_1MatrixBase_html_a98bb9a0f705c6dfde85b0bfff31bf88f"><div class="ttname"><a href="classEigen_1_1MatrixBase.html#a98bb9a0f705c6dfde85b0bfff31bf88f">Eigen::MatrixBase::Identity</a></div><div class="ttdeci">static const IdentityReturnType Identity()</div><div class="ttdef"><b>Definition:</b> CwiseNullaryOp.h:801</div></div>
</div><!-- fragment -->  </td><td><p class="starttd">output: </p><pre class="fragment">1 2 3 0 0
4 5 6 0 0
7 8 9 0 0
0 0 0 1 0
0 0 0 0 1</pre>  <p class="endtd"></p>
</td></tr>
<tr class="alt">
<td>Runtime info </td><td><div class="fragment"><div class="line">vector.size();</div>
<div class="line"> </div>
<div class="line">vector.innerStride();</div>
<div class="line">vector.data();</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">matrix.rows();          matrix.cols();</div>
<div class="line">matrix.innerSize();     matrix.outerSize();</div>
<div class="line">matrix.innerStride();   matrix.outerStride();</div>
<div class="line">matrix.data();</div>
</div><!-- fragment --></td><td class="note">Inner/Outer* are storage order dependent </td></tr>
<tr>
<td>Compile-time info </td><td colspan="2"><div class="fragment"><div class="line">ObjectType::Scalar              ObjectType::RowsAtCompileTime</div>
<div class="line">ObjectType::RealScalar          ObjectType::ColsAtCompileTime</div>
<div class="line">ObjectType::Index               ObjectType::SizeAtCompileTime</div>
</div><!-- fragment --></td><td></td></tr>
<tr class="alt">
<td>Resizing </td><td><div class="fragment"><div class="line">vector.resize(size);</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">vector.resizeLike(other_vector);</div>
<div class="line">vector.conservativeResize(size);</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">matrix.resize(nb_rows, nb_cols);</div>
<div class="line">matrix.resize(Eigen::NoChange, nb_cols);</div>
<div class="line">matrix.resize(nb_rows, Eigen::NoChange);</div>
<div class="line">matrix.resizeLike(other_matrix);</div>
<div class="line">matrix.conservativeResize(nb_rows, nb_cols);</div>
</div><!-- fragment --></td><td class="note"><p class="starttd">no-op if the new sizes match,<br  />
otherwise data are lost<br  />
<br  />
resizing with data preservation</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Coeff access with <br  />
 range checking </td><td><div class="fragment"><div class="line">vector(i)     vector.x()</div>
<div class="line">vector[i]     vector.y()</div>
<div class="line">              vector.z()</div>
<div class="line">              vector.w()</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">matrix(i,j)</div>
</div><!-- fragment --></td><td class="note"><p class="starttd">Range checking is disabled if <br  />
 NDEBUG or EIGEN_NO_DEBUG is defined</p>
<p class="endtd"></p>
</td></tr>
<tr class="alt">
<td>Coeff access without <br  />
 range checking </td><td><div class="fragment"><div class="line">vector.coeff(i)</div>
<div class="line">vector.coeffRef(i)</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">matrix.coeff(i,j)</div>
<div class="line">matrix.coeffRef(i,j)</div>
</div><!-- fragment --></td><td><p class="starttd"></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Assignment/copy </td><td colspan="2"><div class="fragment"><div class="line"><span class="keywordtype">object</span> = expression;</div>
<div class="line">object_of_float = expression_of_double.cast&lt;<span class="keywordtype">float</span>&gt;();</div>
</div><!-- fragment --></td><td class="note"><p class="starttd">the destination is automatically resized (if possible)</p>
<p class="endtd"></p>
</td></tr>
</table>
<h2><a class="anchor" id="QuickRef_PredefMat"></a>
Predefined Matrices</h2>
<table class="manual">
<tr>
<th>Fixed-size matrix or vector </th><th>Dynamic-size matrix </th><th>Dynamic-size vector  </th></tr>
<tr style="border-bottom-style: none;">
<td><div class="fragment"><div class="line"><span class="keyword">typedef</span> {<a class="code" href="group__matrixtypedefs.html#ga276bae130c142e906ad8f47d24d11c1c">Matrix3f</a>|Array33f} FixedXD;</div>
<div class="line">FixedXD x;</div>
<div class="line"> </div>
<div class="line">x = FixedXD::Zero();</div>
<div class="line">x = FixedXD::Ones();</div>
<div class="line">x = FixedXD::Constant(value);</div>
<div class="line">x = FixedXD::Random();</div>
<div class="line">x = FixedXD::LinSpaced(size, low, high);</div>
<div class="line"> </div>
<div class="line">x.setZero();</div>
<div class="line">x.setOnes();</div>
<div class="line">x.setConstant(value);</div>
<div class="line">x.setRandom();</div>
<div class="line">x.setLinSpaced(size, low, high);</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line"><span class="keyword">typedef</span> {<a class="code" href="group__matrixtypedefs.html#ga731599f782380312960376c43450eb48">MatrixXf</a>|ArrayXXf} Dynamic2D;</div>
<div class="line">Dynamic2D x;</div>
<div class="line"> </div>
<div class="line">x = Dynamic2D::Zero(rows, cols);</div>
<div class="line">x = Dynamic2D::Ones(rows, cols);</div>
<div class="line">x = Dynamic2D::Constant(rows, cols, value);</div>
<div class="line">x = Dynamic2D::Random(rows, cols);</div>
<div class="line">N/A</div>
<div class="line"> </div>
<div class="line">x.setZero(rows, cols);</div>
<div class="line">x.setOnes(rows, cols);</div>
<div class="line">x.setConstant(rows, cols, value);</div>
<div class="line">x.setRandom(rows, cols);</div>
<div class="line">N/A</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line"><span class="keyword">typedef</span> {<a class="code" href="group__matrixtypedefs.html#ga8028d921d43acd5605eabad41c254ef2">VectorXf</a>|ArrayXf} Dynamic1D;</div>
<div class="line">Dynamic1D x;</div>
<div class="line"> </div>
<div class="line">x = Dynamic1D::Zero(size);</div>
<div class="line">x = Dynamic1D::Ones(size);</div>
<div class="line">x = Dynamic1D::Constant(size, value);</div>
<div class="line">x = Dynamic1D::Random(size);</div>
<div class="line">x = Dynamic1D::LinSpaced(size, low, high);</div>
<div class="line"> </div>
<div class="line">x.setZero(size);</div>
<div class="line">x.setOnes(size);</div>
<div class="line">x.setConstant(size, value);</div>
<div class="line">x.setRandom(size);</div>
<div class="line">x.setLinSpaced(size, low, high);</div>
</div><!-- fragment -->  <p class="endtd"></p>
</td></tr>
<tr>
<td colspan="3">Identity and <a class="el" href="classEigen_1_1MatrixBase.html#ac7a03a61014f37ddd2fe61ebac0c9539">basis vectors </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a> </td></tr>
<tr style="border-bottom-style: none;">
<td><div class="fragment"><div class="line">x = FixedXD::Identity();</div>
<div class="line">x.setIdentity();</div>
<div class="line"> </div>
<div class="line"><a class="code" href="classEigen_1_1MatrixBase.html#a8a555b7cf626cced54670b98668c4e6d">Vector3f::UnitX</a>() <span class="comment">// 1 0 0</span></div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga5ec9ce2d8adbcd6888f3fbf2e1c095a4">Vector3f</a>::UnitY() <span class="comment">// 0 1 0</span></div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#ga5ec9ce2d8adbcd6888f3fbf2e1c095a4">Vector3f</a>::UnitZ() <span class="comment">// 0 0 1</span></div>
<div class="line"><a class="code" href="group__matrixtypedefs.html#gae6a8e578d2848cc75f573c15a73bd9b4">Vector4f</a>::Unit(i)</div>
<div class="line">x.setUnit(i);</div>
<div class="ttc" id="aclassEigen_1_1MatrixBase_html_a8a555b7cf626cced54670b98668c4e6d"><div class="ttname"><a href="classEigen_1_1MatrixBase.html#a8a555b7cf626cced54670b98668c4e6d">Eigen::MatrixBase::UnitX</a></div><div class="ttdeci">static const BasisReturnType UnitX()</div><div class="ttdef"><b>Definition:</b> CwiseNullaryOp.h:932</div></div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">x = Dynamic2D::Identity(rows, cols);</div>
<div class="line">x.setIdentity(rows, cols);</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">N/A</div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">N/A</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code" href="classEigen_1_1MatrixBase.html#ac7a03a61014f37ddd2fe61ebac0c9539">VectorXf::Unit</a>(size,i)</div>
<div class="line">x.setUnit(size,i);</div>
<div class="line"><a class="code" href="classEigen_1_1MatrixBase.html#ac7a03a61014f37ddd2fe61ebac0c9539">VectorXf::Unit</a>(4,1) == <a class="code" href="group__matrixtypedefs.html#gae6a8e578d2848cc75f573c15a73bd9b4">Vector4f</a>(0,1,0,0)</div>
<div class="line">                    == <a class="code" href="classEigen_1_1MatrixBase.html#a00850083489e20249b1d05b394fc5efc">Vector4f::UnitY</a>()</div>
<div class="ttc" id="aclassEigen_1_1MatrixBase_html_a00850083489e20249b1d05b394fc5efc"><div class="ttname"><a href="classEigen_1_1MatrixBase.html#a00850083489e20249b1d05b394fc5efc">Eigen::MatrixBase::UnitY</a></div><div class="ttdeci">static const BasisReturnType UnitY()</div><div class="ttdef"><b>Definition:</b> CwiseNullaryOp.h:942</div></div>
<div class="ttc" id="aclassEigen_1_1MatrixBase_html_ac7a03a61014f37ddd2fe61ebac0c9539"><div class="ttname"><a href="classEigen_1_1MatrixBase.html#ac7a03a61014f37ddd2fe61ebac0c9539">Eigen::MatrixBase::Unit</a></div><div class="ttdeci">static const BasisReturnType Unit(Index size, Index i)</div><div class="ttdef"><b>Definition:</b> CwiseNullaryOp.h:904</div></div>
</div><!-- fragment -->   </td></tr>
</table>
<p>Note that it is allowed to call any of the <code>set*</code> functions to a dynamic-sized vector or matrix without passing new sizes. For instance: </p><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gaceba5f63d4040c79c44109590d4fa606">MatrixXi</a> M(3,3);</div>
<div class="line">M.setIdentity();</div>
<div class="ttc" id="agroup__matrixtypedefs_html_gaceba5f63d4040c79c44109590d4fa606"><div class="ttname"><a href="group__matrixtypedefs.html#gaceba5f63d4040c79c44109590d4fa606">Eigen::MatrixXi</a></div><div class="ttdeci">Matrix&lt; int, Dynamic, Dynamic &gt; MatrixXi</div><div class="ttdoc">Dynamic×Dynamic matrix of type int.</div><div class="ttdef"><b>Definition:</b> Matrix.h:499</div></div>
</div><!-- fragment --><h2><a class="anchor" id="QuickRef_Map"></a>
Mapping external arrays</h2>
<table class="manual">
<tr>
<td>Contiguous <br  />
 memory </td><td><div class="fragment"><div class="line"><span class="keywordtype">float</span> data[] = {1,2,3,4};</div>
<div class="line">Map&lt;Vector3f&gt; v1(data);       <span class="comment">// uses v1 as a Vector3f object</span></div>
<div class="line">Map&lt;ArrayXf&gt;  v2(data,3);     <span class="comment">// uses v2 as a ArrayXf object</span></div>
<div class="line">Map&lt;Array22f&gt; m1(data);       <span class="comment">// uses m1 as a Array22f object</span></div>
<div class="line">Map&lt;MatrixXf&gt; m2(data,2,2);   <span class="comment">// uses m2 as a MatrixXf object</span></div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Typical usage <br  />
 of strides </td><td><div class="fragment"><div class="line"><span class="keywordtype">float</span> data[] = {1,2,3,4,5,6,7,8,9};</div>
<div class="line">Map&lt;VectorXf,0,InnerStride&lt;2&gt; &gt;  v1(data,3);                      <span class="comment">// = [1,3,5]</span></div>
<div class="line">Map&lt;VectorXf,0,InnerStride&lt;&gt; &gt;   v2(data,3,InnerStride&lt;&gt;(3));     <span class="comment">// = [1,4,7]</span></div>
<div class="line">Map&lt;MatrixXf,0,OuterStride&lt;3&gt; &gt;  m2(data,2,3);                    <span class="comment">// both lines     |1,4,7|</span></div>
<div class="line">Map&lt;MatrixXf,0,OuterStride&lt;&gt; &gt;   m1(data,2,3,OuterStride&lt;&gt;(3));   <span class="comment">// are equal to:  |2,5,8|</span></div>
</div><!-- fragment -->  </td></tr>
</table>
<p><a href="#" class="top">top</a> </p>
<h1><a class="anchor" id="QuickRef_ArithmeticOperators"></a>
Arithmetic Operators</h1>
<table class="manual">
<tr>
<td>add <br  />
 subtract</td><td><div class="fragment"><div class="line">mat3 = mat1 + mat2;           mat3 += mat1;</div>
<div class="line">mat3 = mat1 - mat2;           mat3 -= mat1;</div>
</div><!-- fragment -->  </td></tr>
<tr class="alt">
<td>scalar product</td><td><div class="fragment"><div class="line">mat3 = mat1 * s1;             mat3 *= s1;           mat3 = s1 * mat1;</div>
<div class="line">mat3 = mat1 / s1;             mat3 /= s1;</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>matrix/vector <br  />
 products <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line">col2 = mat1 * col1;</div>
<div class="line">row2 = row1 * mat1;           row1 *= mat1;</div>
<div class="line">mat3 = mat1 * mat2;           mat3 *= mat1; </div>
</div><!-- fragment -->  </td></tr>
<tr class="alt">
<td>transposition <br  />
 adjoint <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line">mat1 = mat2.transpose();      mat1.transposeInPlace();</div>
<div class="line">mat1 = mat2.adjoint();        mat1.adjointInPlace();</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td><a class="el" href="classEigen_1_1MatrixBase.html#adfd32bf5fcf6ee603c924dde9bf7bc39">dot </a> product <br  />
 inner product <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line">scalar = vec1.dot(vec2);</div>
<div class="line">scalar = col1.adjoint() * col2;</div>
<div class="line">scalar = (col1.adjoint() * col2).value();</div>
</div><!-- fragment -->  </td></tr>
<tr class="alt">
<td>outer product <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line">mat = col1 * col2.transpose();</div>
</div><!-- fragment --> <p class="endtd"></p>
</td></tr>
<tr>
<td><a class="el" href="classEigen_1_1MatrixBase.html#a196c4ec3c8ffdf5bda45d0f617154975">norm </a> <br  />
 <a class="el" href="classEigen_1_1MatrixBase.html#a5cf2fd4c57e59604fd4116158fd34308">normalization </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line">scalar = vec1.norm();         scalar = vec1.squaredNorm()</div>
<div class="line">vec2 = vec1.normalized();     vec1.normalize(); <span class="comment">// inplace </span></div>
</div><!-- fragment --> <p class="endtd"></p>
</td></tr>
<tr class="alt">
<td><a class="el" href="group__Geometry__Module.html#ga0024b44eca99cb7135887c2aaf319d28">cross product </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></td><td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Geometry&gt;</span></div>
<div class="line">vec3 = vec1.cross(vec2);</div>
</div><!-- fragment --> </td></tr>
</table>
<p><a href="#" class="top">top</a> </p>
<h1><a class="anchor" id="QuickRef_Coeffwise"></a>
Coefficient-wise &amp; Array operators</h1>
<p>In addition to the aforementioned operators, <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> supports numerous coefficient-wise operator and functions. Most of them unambiguously makes sense in array-world<a href="#arrayonly" style="color:blue;text-decoration: none;">*</a>. The following operators are readily available for arrays, or available through .array() for vectors and matrices:</p>
<table class="manual">
<tr>
<td>Arithmetic operators</td><td><div class="fragment"><div class="line">array1 * array2     array1 / array2     array1 *= array2    array1 /= array2</div>
<div class="line">array1 + scalar     array1 - scalar     array1 += scalar    array1 -= scalar</div>
</div><!-- fragment --> </td></tr>
<tr>
<td>Comparisons</td><td><div class="fragment"><div class="line">array1 &lt; array2     array1 &gt; array2     array1 &lt; scalar     array1 &gt; scalar</div>
<div class="line">array1 &lt;= array2    array1 &gt;= array2    array1 &lt;= scalar    array1 &gt;= scalar</div>
<div class="line">array1 == array2    array1 != array2    array1 == scalar    array1 != scalar</div>
<div class="line">array1.min(array2)  array1.max(array2)  array1.min(scalar)  array1.max(scalar)</div>
</div><!-- fragment --> </td></tr>
<tr>
<td>Trigo, power, and <br  />
 misc functions <br  />
 and the STL-like variants</td><td><div class="fragment"><div class="line">array1.abs2()</div>
<div class="line">array1.abs()                  <a class="code" href="namespaceEigen.html#ae27242789e7e62a8c42579b79be59b1a">abs</a>(array1)</div>
<div class="line">array1.sqrt()                 <a class="code" href="namespaceEigen.html#af4f536e8ea56702e63088efb3706d1f0">sqrt</a>(array1)</div>
<div class="line">array1.log()                  <a class="code" href="namespaceEigen.html#ae8bb75ba4f5f30a7571146dbfa653c6d">log</a>(array1)</div>
<div class="line">array1.log10()                <a class="code" href="namespaceEigen.html#a25256faeec3ffd0f3615a0e1e45dfb14">log10</a>(array1)</div>
<div class="line">array1.exp()                  <a class="code" href="namespaceEigen.html#ae491aecf7dab66ac7e11008c5766694d">exp</a>(array1)</div>
<div class="line">array1.pow(array2)            pow(array1,array2)</div>
<div class="line">array1.pow(scalar)            pow(array1,scalar)</div>
<div class="line">                              pow(scalar,array2)</div>
<div class="line">array1.square()</div>
<div class="line">array1.cube()</div>
<div class="line">array1.inverse()</div>
<div class="line"> </div>
<div class="line">array1.sin()                  <a class="code" href="namespaceEigen.html#ae6e8ad270ff41c088d7651567594f796">sin</a>(array1)</div>
<div class="line">array1.cos()                  <a class="code" href="namespaceEigen.html#ad01d50a42869218f1d54af13f71517a6">cos</a>(array1)</div>
<div class="line">array1.tan()                  <a class="code" href="namespaceEigen.html#a3bc116a6243f38c22f851581aa7b521a">tan</a>(array1)</div>
<div class="line">array1.asin()                 <a class="code" href="namespaceEigen.html#a6c5c246b877ac331495d21e7a5d51616">asin</a>(array1)</div>
<div class="line">array1.acos()                 <a class="code" href="namespaceEigen.html#a3fe3a136370fefae062591304c6a7ebd">acos</a>(array1)</div>
<div class="line">array1.atan()                 <a class="code" href="namespaceEigen.html#a230744e17147d12e8ef3f2fc3796f64f">atan</a>(array1)</div>
<div class="line">array1.sinh()                 <a class="code" href="namespaceEigen.html#af284ce359b6efd4b594a9f8a1f5e5d96">sinh</a>(array1)</div>
<div class="line">array1.cosh()                 <a class="code" href="namespaceEigen.html#a34b99a26a2a1e7ff985a5ace16eedfcb">cosh</a>(array1)</div>
<div class="line">array1.tanh()                 <a class="code" href="namespaceEigen.html#a0110c233d357169fd58fdf5656992a98">tanh</a>(array1)</div>
<div class="line">array1.arg()                  <a class="code" href="namespaceEigen.html#aa539408a09481d35961e11ee78793db1">arg</a>(array1)</div>
<div class="line"> </div>
<div class="line">array1.floor()                <a class="code" href="namespaceEigen.html#abf03d773a87830bc7fde51bcd94c89a0">floor</a>(array1)</div>
<div class="line">array1.ceil()                 <a class="code" href="namespaceEigen.html#aa73e38be0689a463ae14141b9cf89c35">ceil</a>(array1)</div>
<div class="line">array1.round()                <a class="code" href="namespaceEigen.html#ad9eaa98e8016ef17024a18a2f3e5bef3">round</a>(aray1)</div>
<div class="line"> </div>
<div class="line">array1.isFinite()             <a class="code" href="namespaceEigen.html#aba24ec81dec745a00b7f33adead89811">isfinite</a>(array1)</div>
<div class="line">array1.isInf()                <a class="code" href="namespaceEigen.html#a1f1103712e337c4c96a05f949637a4c8">isinf</a>(array1)</div>
<div class="line">array1.isNaN()                <a class="code" href="namespaceEigen.html#a99adfc5178f3fd5488304284388b2a10">isnan</a>(array1)</div>
<div class="ttc" id="anamespaceEigen_html_a0110c233d357169fd58fdf5656992a98"><div class="ttname"><a href="namespaceEigen.html#a0110c233d357169fd58fdf5656992a98">Eigen::tanh</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_tanh_op&lt; typename Derived::Scalar &gt;, const Derived &gt; tanh(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a1f1103712e337c4c96a05f949637a4c8"><div class="ttname"><a href="namespaceEigen.html#a1f1103712e337c4c96a05f949637a4c8">Eigen::isinf</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_isinf_op&lt; typename Derived::Scalar &gt;, const Derived &gt; isinf(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a230744e17147d12e8ef3f2fc3796f64f"><div class="ttname"><a href="namespaceEigen.html#a230744e17147d12e8ef3f2fc3796f64f">Eigen::atan</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_atan_op&lt; typename Derived::Scalar &gt;, const Derived &gt; atan(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a25256faeec3ffd0f3615a0e1e45dfb14"><div class="ttname"><a href="namespaceEigen.html#a25256faeec3ffd0f3615a0e1e45dfb14">Eigen::log10</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_log10_op&lt; typename Derived::Scalar &gt;, const Derived &gt; log10(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a34b99a26a2a1e7ff985a5ace16eedfcb"><div class="ttname"><a href="namespaceEigen.html#a34b99a26a2a1e7ff985a5ace16eedfcb">Eigen::cosh</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_cosh_op&lt; typename Derived::Scalar &gt;, const Derived &gt; cosh(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a3bc116a6243f38c22f851581aa7b521a"><div class="ttname"><a href="namespaceEigen.html#a3bc116a6243f38c22f851581aa7b521a">Eigen::tan</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_tan_op&lt; typename Derived::Scalar &gt;, const Derived &gt; tan(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a3fe3a136370fefae062591304c6a7ebd"><div class="ttname"><a href="namespaceEigen.html#a3fe3a136370fefae062591304c6a7ebd">Eigen::acos</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_acos_op&lt; typename Derived::Scalar &gt;, const Derived &gt; acos(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a6c5c246b877ac331495d21e7a5d51616"><div class="ttname"><a href="namespaceEigen.html#a6c5c246b877ac331495d21e7a5d51616">Eigen::asin</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_asin_op&lt; typename Derived::Scalar &gt;, const Derived &gt; asin(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_a99adfc5178f3fd5488304284388b2a10"><div class="ttname"><a href="namespaceEigen.html#a99adfc5178f3fd5488304284388b2a10">Eigen::isnan</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_isnan_op&lt; typename Derived::Scalar &gt;, const Derived &gt; isnan(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_aa539408a09481d35961e11ee78793db1"><div class="ttname"><a href="namespaceEigen.html#aa539408a09481d35961e11ee78793db1">Eigen::arg</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_arg_op&lt; typename Derived::Scalar &gt;, const Derived &gt; arg(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_aa73e38be0689a463ae14141b9cf89c35"><div class="ttname"><a href="namespaceEigen.html#aa73e38be0689a463ae14141b9cf89c35">Eigen::ceil</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_ceil_op&lt; typename Derived::Scalar &gt;, const Derived &gt; ceil(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_aba24ec81dec745a00b7f33adead89811"><div class="ttname"><a href="namespaceEigen.html#aba24ec81dec745a00b7f33adead89811">Eigen::isfinite</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_isfinite_op&lt; typename Derived::Scalar &gt;, const Derived &gt; isfinite(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_abf03d773a87830bc7fde51bcd94c89a0"><div class="ttname"><a href="namespaceEigen.html#abf03d773a87830bc7fde51bcd94c89a0">Eigen::floor</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_floor_op&lt; typename Derived::Scalar &gt;, const Derived &gt; floor(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ad01d50a42869218f1d54af13f71517a6"><div class="ttname"><a href="namespaceEigen.html#ad01d50a42869218f1d54af13f71517a6">Eigen::cos</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_cos_op&lt; typename Derived::Scalar &gt;, const Derived &gt; cos(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ad9eaa98e8016ef17024a18a2f3e5bef3"><div class="ttname"><a href="namespaceEigen.html#ad9eaa98e8016ef17024a18a2f3e5bef3">Eigen::round</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_round_op&lt; typename Derived::Scalar &gt;, const Derived &gt; round(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ae27242789e7e62a8c42579b79be59b1a"><div class="ttname"><a href="namespaceEigen.html#ae27242789e7e62a8c42579b79be59b1a">Eigen::abs</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_abs_op&lt; typename Derived::Scalar &gt;, const Derived &gt; abs(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ae491aecf7dab66ac7e11008c5766694d"><div class="ttname"><a href="namespaceEigen.html#ae491aecf7dab66ac7e11008c5766694d">Eigen::exp</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_exp_op&lt; typename Derived::Scalar &gt;, const Derived &gt; exp(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ae6e8ad270ff41c088d7651567594f796"><div class="ttname"><a href="namespaceEigen.html#ae6e8ad270ff41c088d7651567594f796">Eigen::sin</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_sin_op&lt; typename Derived::Scalar &gt;, const Derived &gt; sin(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ae8bb75ba4f5f30a7571146dbfa653c6d"><div class="ttname"><a href="namespaceEigen.html#ae8bb75ba4f5f30a7571146dbfa653c6d">Eigen::log</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_log_op&lt; typename Derived::Scalar &gt;, const Derived &gt; log(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_af284ce359b6efd4b594a9f8a1f5e5d96"><div class="ttname"><a href="namespaceEigen.html#af284ce359b6efd4b594a9f8a1f5e5d96">Eigen::sinh</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_sinh_op&lt; typename Derived::Scalar &gt;, const Derived &gt; sinh(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_af4f536e8ea56702e63088efb3706d1f0"><div class="ttname"><a href="namespaceEigen.html#af4f536e8ea56702e63088efb3706d1f0">Eigen::sqrt</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_sqrt_op&lt; typename Derived::Scalar &gt;, const Derived &gt; sqrt(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
</div><!-- fragment -->  </td></tr>
</table>
<p>The following coefficient-wise operators are available for all kind of expressions (matrices, vectors, and arrays), and for both real or complex scalar types:</p>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>'s API</th><th>STL-like APIs<a href="#arrayonly" style="color:blue;text-decoration: none;">*</a> </th><th>Comments </th></tr>
<tr>
<td><div class="fragment"><div class="line">mat1.real()</div>
<div class="line">mat1.imag()</div>
<div class="line">mat1.conjugate()</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line"><a class="code" href="namespaceEigen.html#ac74dc920119b1eba45e9218d9f402afc">real</a>(array1)</div>
<div class="line"><a class="code" href="namespaceEigen.html#a04d60a3c8a266f63c08e03615c1985c9">imag</a>(array1)</div>
<div class="line"><a class="code" href="namespaceEigen.html#ab84f39a06a18e1ebb23f8be80345b79d">conj</a>(array1)</div>
<div class="ttc" id="anamespaceEigen_html_a04d60a3c8a266f63c08e03615c1985c9"><div class="ttname"><a href="namespaceEigen.html#a04d60a3c8a266f63c08e03615c1985c9">Eigen::imag</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_imag_op&lt; typename Derived::Scalar &gt;, const Derived &gt; imag(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ab84f39a06a18e1ebb23f8be80345b79d"><div class="ttname"><a href="namespaceEigen.html#ab84f39a06a18e1ebb23f8be80345b79d">Eigen::conj</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_conjugate_op&lt; typename Derived::Scalar &gt;, const Derived &gt; conj(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
<div class="ttc" id="anamespaceEigen_html_ac74dc920119b1eba45e9218d9f402afc"><div class="ttname"><a href="namespaceEigen.html#ac74dc920119b1eba45e9218d9f402afc">Eigen::real</a></div><div class="ttdeci">const Eigen::CwiseUnaryOp&lt; Eigen::internal::scalar_real_op&lt; typename Derived::Scalar &gt;, const Derived &gt; real(const Eigen::ArrayBase&lt; Derived &gt; &amp;x)</div></div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line"><span class="comment">// read-write, no-op for real expressions</span></div>
<div class="line"><span class="comment">// read-only for real, read-write for complexes</span></div>
<div class="line"><span class="comment">// no-op for real expressions</span></div>
</div><!-- fragment -->  </td></tr>
</table>
<p>Some coefficient-wise operators are readily available for for matrices and vectors through the following cwise* methods: </p><table class="manual">
<tr>
<th><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> API <a href="#matrixonly" style="color:green;text-decoration: none;">*</a></th><th>Via <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> conversions </th></tr>
<tr>
<td><div class="fragment"><div class="line">mat1.cwiseMin(mat2)         mat1.cwiseMin(scalar)</div>
<div class="line">mat1.cwiseMax(mat2)         mat1.cwiseMax(scalar)</div>
<div class="line">mat1.cwiseAbs2()</div>
<div class="line">mat1.cwiseAbs()</div>
<div class="line">mat1.cwiseSqrt()</div>
<div class="line">mat1.cwiseInverse()</div>
<div class="line">mat1.cwiseProduct(mat2)</div>
<div class="line">mat1.cwiseQuotient(mat2)</div>
<div class="line">mat1.cwiseEqual(mat2)       mat1.cwiseEqual(scalar)</div>
<div class="line">mat1.cwiseNotEqual(mat2)</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">mat1.array().min(mat2.array())    mat1.array().min(scalar)</div>
<div class="line">mat1.array().max(mat2.array())    mat1.array().max(scalar)</div>
<div class="line">mat1.array().abs2()</div>
<div class="line">mat1.array().abs()</div>
<div class="line">mat1.array().sqrt()</div>
<div class="line">mat1.array().inverse()</div>
<div class="line">mat1.array() * mat2.array()</div>
<div class="line">mat1.array() / mat2.array()</div>
<div class="line">mat1.array() == mat2.array()      mat1.array() == scalar</div>
<div class="line">mat1.array() != mat2.array()</div>
</div><!-- fragment --> </td></tr>
</table>
<p>The main difference between the two API is that the one based on cwise* methods returns an expression in the matrix world, while the second one (based on .array()) returns an array expression. Recall that .array() has no cost, it only changes the available API and interpretation of the data.</p>
<p>It is also very simple to apply any user defined function <code>foo</code> using DenseBase::unaryExpr together with <a href="http://en.cppreference.com/w/cpp/utility/functional/ptr_fun">std::ptr_fun</a> (c++03, deprecated or removed in newer C++ versions), <a href="http://en.cppreference.com/w/cpp/utility/functional/ref">std::ref</a> (c++11), or <a href="http://en.cppreference.com/w/cpp/language/lambda">lambdas</a> (c++11): </p><div class="fragment"><div class="line">mat1.unaryExpr(std::ptr_fun(foo));</div>
<div class="line">mat1.unaryExpr(std::ref(foo));</div>
<div class="line">mat1.unaryExpr([](<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> foo(x); });</div>
</div><!-- fragment --><p>Please note that it's not possible to pass a raw function pointer to <code>unaryExpr</code>, so please warp it as shown above.</p>
<p><a href="#" class="top">top</a> </p>
<h1><a class="anchor" id="QuickRef_Reductions"></a>
Reductions</h1>
<p><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> provides several reduction methods such as: <a class="el" href="classEigen_1_1DenseBase.html#a0739f9c868c331031c7810e21838dcb2">minCoeff() </a>, <a class="el" href="classEigen_1_1DenseBase.html#a7e6987d106f1cca3ac6ab36d288cc8e1">maxCoeff() </a>, <a class="el" href="classEigen_1_1DenseBase.html#addd7080d5c202795820e361768d0140c">sum() </a>, <a class="el" href="classEigen_1_1DenseBase.html#af119d9a4efe5a15cd83c1ccdf01b3a4f">prod() </a>, <a class="el" href="classEigen_1_1MatrixBase.html#a544b609f65eb2bd3e368b3fc2d79479e">trace() </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a>, <a class="el" href="classEigen_1_1MatrixBase.html#a196c4ec3c8ffdf5bda45d0f617154975">norm() </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a>, <a class="el" href="classEigen_1_1MatrixBase.html#ac8da566526419f9742a6c471bbd87e0a">squaredNorm() </a> <a href="#matrixonly" style="color:green;text-decoration: none;">*</a>, <a class="el" href="classEigen_1_1DenseBase.html#ae42ab60296c120e9f45ce3b44e1761a4">all() </a>, and <a class="el" href="classEigen_1_1DenseBase.html#abfbf4cb72dd577e62fbe035b1c53e695">any() </a>. All reduction operations can be done matrix-wise, <a class="el" href="classEigen_1_1DenseBase.html#a1c0e1b6067ec1de6cb8799da55aa7d30">column-wise </a> or <a class="el" href="classEigen_1_1DenseBase.html#a6daa3a3156ca0e0722bf78638e1c7f28">row-wise </a>. Usage example: </p><table class="manual">
<tr>
<td rowspan="3" style="border-right-style:dashed;vertical-align:middle"><div class="fragment"><div class="line">      5 3 1</div>
<div class="line">mat = 2 7 8</div>
<div class="line">      9 4 6 </div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">mat.minCoeff(); </div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">1 </div>
</div><!-- fragment --> </td></tr>
<tr class="alt">
<td><div class="fragment"><div class="line">mat.colwise().minCoeff(); </div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">2 3 1 </div>
</div><!-- fragment --> </td></tr>
<tr style="vertical-align:middle">
<td><div class="fragment"><div class="line">mat.rowwise().minCoeff(); </div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">1</div>
<div class="line">2</div>
<div class="line">4</div>
</div><!-- fragment --> </td></tr>
</table>
<p>Special versions of <a class="el" href="classEigen_1_1DenseBase.html#aa28152ba4a42b2d112e5fec5469ec4c1">minCoeff </a> and <a class="el" href="classEigen_1_1DenseBase.html#a3780b7a9cd184d0b4f3ea797eba9e2b3">maxCoeff </a>: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> i, j;</div>
<div class="line">s = vector.minCoeff(&amp;i);        <span class="comment">// s == vector[i]</span></div>
<div class="line">s = matrix.maxCoeff(&amp;i, &amp;j);    <span class="comment">// s == matrix(i,j)</span></div>
</div><!-- fragment --><p> Typical use cases of <a class="el" href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">all()</a> and any(): </p><div class="fragment"><div class="line"><span class="keywordflow">if</span>((array1 &gt; 0).<a class="code" href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">all</a>()) ...      <span class="comment">// if all coefficients of array1 are greater than 0 ...</span></div>
<div class="line"><span class="keywordflow">if</span>((array1 &lt; array2).any()) ... <span class="comment">// if there exist a pair i,j such that array1(i,j) &lt; array2(i,j) ...</span></div>
<div class="ttc" id="agroup__Core__Module_html_ga4abe6022fbef6cda264ef2947a2be1a9"><div class="ttname"><a href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">Eigen::placeholders::all</a></div><div class="ttdeci">static const Eigen::internal::all_t all</div><div class="ttdef"><b>Definition:</b> IndexedViewHelper.h:189</div></div>
</div><!-- fragment --><p><a href="#" class="top">top</a></p>
<h1><a class="anchor" id="QuickRef_Blocks"></a>
Sub-matrices</h1>
<div class="warningbox"> <b>PLEASE HELP US IMPROVING THIS SECTION.</b> Eigen 3.4 supports a much improved API for sub-matrices, including, slicing and indexing from arrays: <a class="el" href="group__TutorialSlicingIndexing.html">Slicing and Indexing</a> </div><p>Read-write access to a <a class="el" href="">column </a> or a <a class="el" href="">row </a> of a matrix (or array): </p><div class="fragment"><div class="line">mat1.row(i) = mat2.col(j);</div>
<div class="line">mat1.col(j1).swap(mat1.col(j2));</div>
</div><!-- fragment --><p>Read-write access to sub-vectors: </p><table class="manual">
<tr>
<th>Default versions </th><th>Optimized versions when the size <br  />
 is known at compile time </th><th><p class="starttd"></p>
<p class="endtd"></p>
</th></tr>
<tr>
<td><div class="fragment"><div class="line">vec1.head(n)</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">vec1.head&lt;n&gt;()</div>
</div><!-- fragment --></td><td>the first <code>n</code> coeffs  </td></tr>
<tr>
<td><div class="fragment"><div class="line">vec1.tail(n)</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">vec1.tail&lt;n&gt;()</div>
</div><!-- fragment --></td><td>the last <code>n</code> coeffs  </td></tr>
<tr>
<td><div class="fragment"><div class="line">vec1.segment(pos,n)</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">vec1.segment&lt;n&gt;(pos)</div>
</div><!-- fragment --> </td><td>the <code>n</code> coeffs in the <br  />
 range [<code>pos</code> : <code>pos</code> + <code>n</code> - 1] </td></tr>
<tr class="alt">
<td colspan="3"><p class="starttd"></p>
<p class="endtd">Read-write access to sub-matrices: </p>
</td></tr>
<tr>
<td><div class="fragment"><div class="line">mat1.block(i,j,rows,cols)</div>
</div><!-- fragment --> <a class="el" href="">(more) </a> </td><td><div class="fragment"><div class="line">mat1.block&lt;rows,cols&gt;(i,j)</div>
</div><!-- fragment --> <a class="el" href="">(more) </a> </td><td>the <code>rows</code> x <code>cols</code> sub-matrix <br  />
 starting from position (<code>i</code>,<code>j</code>) </td></tr>
<tr>
<td><div class="fragment"><div class="line">mat1.topLeftCorner(rows,cols)</div>
<div class="line">mat1.topRightCorner(rows,cols)</div>
<div class="line">mat1.bottomLeftCorner(rows,cols)</div>
<div class="line">mat1.bottomRightCorner(rows,cols)</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">mat1.topLeftCorner&lt;rows,cols&gt;()</div>
<div class="line">mat1.topRightCorner&lt;rows,cols&gt;()</div>
<div class="line">mat1.bottomLeftCorner&lt;rows,cols&gt;()</div>
<div class="line">mat1.bottomRightCorner&lt;rows,cols&gt;()</div>
</div><!-- fragment --> </td><td>the <code>rows</code> x <code>cols</code> sub-matrix <br  />
 taken in one of the four corners </td></tr>
<tr>
<td><div class="fragment"><div class="line">mat1.topRows(rows)</div>
<div class="line">mat1.bottomRows(rows)</div>
<div class="line">mat1.leftCols(cols)</div>
<div class="line">mat1.rightCols(cols)</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">mat1.topRows&lt;rows&gt;()</div>
<div class="line">mat1.bottomRows&lt;rows&gt;()</div>
<div class="line">mat1.leftCols&lt;cols&gt;()</div>
<div class="line">mat1.rightCols&lt;cols&gt;()</div>
</div><!-- fragment --> </td><td>specialized versions of block() <br  />
 when the block fit two corners </td></tr>
</table>
<p><a href="#" class="top">top</a></p>
<h1><a class="anchor" id="QuickRef_Misc"></a>
Miscellaneous operations</h1>
<div class="warningbox"> <b>PLEASE HELP US IMPROVING THIS SECTION.</b> Eigen 3.4 supports a new API for reshaping: <a class="el" href="group__TutorialReshape.html">Reshape</a> </div><h2><a class="anchor" id="QuickRef_Reverse"></a>
Reverse</h2>
<p>Vectors, rows, and/or columns of a matrix can be reversed (see <a class="el" href="classEigen_1_1DenseBase.html#a38ea394036d8b096abf322469c80198f">DenseBase::reverse()</a>, <a class="el" href="classEigen_1_1DenseBase.html#adb8045155ea45f7961fc2a5170e1d921">DenseBase::reverseInPlace()</a>, <a class="el" href="classEigen_1_1VectorwiseOp.html#ab8caf5367e2bd636536c8a0e0c89fe15">VectorwiseOp::reverse()</a>). </p><div class="fragment"><div class="line">vec.reverse()           mat.colwise().reverse()   mat.rowwise().reverse()</div>
<div class="line">vec.reverseInPlace()</div>
</div><!-- fragment --><h2><a class="anchor" id="QuickRef_Replicate"></a>
Replicate</h2>
<p>Vectors, matrices, rows, and/or columns can be replicated in any direction (see <a class="el" href="classEigen_1_1DenseBase.html#a60dadfe80b813d808e91e4521c722a8e">DenseBase::replicate()</a>, <a class="el" href="classEigen_1_1VectorwiseOp.html#a5f0c8dc9e9c4aeaa2057f15800f5c18c">VectorwiseOp::replicate()</a>) </p><div class="fragment"><div class="line">vec.replicate(times)                                          vec.replicate&lt;Times&gt;</div>
<div class="line">mat.replicate(vertical_times, horizontal_times)               mat.replicate&lt;VerticalTimes, HorizontalTimes&gt;()</div>
<div class="line">mat.colwise().replicate(vertical_times, horizontal_times)     mat.colwise().replicate&lt;VerticalTimes, HorizontalTimes&gt;()</div>
<div class="line">mat.rowwise().replicate(vertical_times, horizontal_times)     mat.rowwise().replicate&lt;VerticalTimes, HorizontalTimes&gt;()</div>
</div><!-- fragment --><p><a href="#" class="top">top</a></p>
<h1><a class="anchor" id="QuickRef_DiagTriSymm"></a>
Diagonal, Triangular, and Self-adjoint matrices</h1>
<p>(matrix world <a href="#matrixonly" style="color:green;text-decoration: none;">*</a>)</p>
<h2><a class="anchor" id="QuickRef_Diagonal"></a>
Diagonal matrices</h2>
<table class="example">
<tr>
<th>Operation</th><th>Code </th></tr>
<tr>
<td>view a vector <a class="el" href="classEigen_1_1MatrixBase.html#a14235b62c90f93fe910070b4743782d0">as a diagonal matrix </a> <br  />
 </td><td><div class="fragment"><div class="line">mat1 = vec1.asDiagonal();</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Declare a diagonal matrix</td><td><div class="fragment"><div class="line">DiagonalMatrix&lt;Scalar,SizeAtCompileTime&gt; diag1(size);</div>
<div class="line">diag1.diagonal() = vector;</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Access the <a class="el" href="classEigen_1_1MatrixBase.html#a2d641a5804fff1c3db99a84ea93ecb63">diagonal </a> and <a class="el" href="classEigen_1_1MatrixBase.html#a3af2b2e5d1fc3fd4a15750b2f9153762">super/sub diagonals </a> of a matrix as a vector (read/write) </td><td><div class="fragment"><div class="line">vec1 = mat1.diagonal();        mat1.diagonal() = vec1;      <span class="comment">// main diagonal</span></div>
<div class="line">vec1 = mat1.diagonal(+n);      mat1.diagonal(+n) = vec1;    <span class="comment">// n-th super diagonal</span></div>
<div class="line">vec1 = mat1.diagonal(-n);      mat1.diagonal(-n) = vec1;    <span class="comment">// n-th sub diagonal</span></div>
<div class="line">vec1 = mat1.diagonal&lt;1&gt;();     mat1.diagonal&lt;1&gt;() = vec1;   <span class="comment">// first super diagonal</span></div>
<div class="line">vec1 = mat1.diagonal&lt;-2&gt;();    mat1.diagonal&lt;-2&gt;() = vec1;  <span class="comment">// second sub diagonal</span></div>
</div><!-- fragment --> <p class="endtd"></p>
</td></tr>
<tr>
<td>Optimized products and inverse </td><td><div class="fragment"><div class="line">mat3  = scalar * diag1 * mat1;</div>
<div class="line">mat3 += scalar * mat1 * vec1.asDiagonal();</div>
<div class="line">mat3 = vec1.asDiagonal().inverse() * mat1</div>
<div class="line">mat3 = mat1 * diag1.inverse()</div>
</div><!-- fragment --> <p class="endtd"></p>
</td></tr>
</table>
<h2><a class="anchor" id="QuickRef_TriangularView"></a>
Triangular views</h2>
<p><a class="el" href="classEigen_1_1TriangularView.html" title="Expression of a triangular part in a matrix.">TriangularView</a> gives a view on a triangular part of a dense matrix and allows to perform optimized operations on it. The opposite triangular part is never referenced and can be used to store other information.</p>
<dl class="section note"><dt>Note</dt><dd>The .triangularView() template member function requires the <code>template</code> keyword if it is used on an object of a type that depends on a template parameter; see <a class="el" href="TopicTemplateKeyword.html">The template and typename keywords in C++</a> for details.</dd></dl>
<table class="example">
<tr>
<th>Operation</th><th>Code </th></tr>
<tr>
<td>Reference to a triangular with optional <br  />
unit or null diagonal (read/write): </td><td><div class="fragment"><div class="line">m.triangularView&lt;Xxx&gt;()</div>
</div><!-- fragment --> <br  />
<code>Xxx</code> = <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>, <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a>, <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda7b37877e0b9b0df28c9c2b669a633265">StrictlyUpper</a>, <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">StrictlyLower</a>, <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">UnitUpper</a>, <a class="el" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda">UnitLower</a>  </td></tr>
<tr>
<td>Writing to a specific triangular part:<br  />
 (only the referenced triangular part is evaluated) </td><td><div class="fragment"><div class="line">m1.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;() = m2 + m3 </div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a></div><div class="ttdeci">@ Lower</div><div class="ttdef"><b>Definition:</b> Constants.h:211</div></div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Conversion to a dense matrix setting the opposite triangular part to zero: </td><td><div class="fragment"><div class="line">m2 = m1.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">Eigen::UnitUpper</a>&gt;()</div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">Eigen::UnitUpper</a></div><div class="ttdeci">@ UnitUpper</div><div class="ttdef"><b>Definition:</b> Constants.h:221</div></div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Products: </td><td><div class="fragment"><div class="line">m3 += s1 * m1.adjoint().triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">Eigen::UnitUpper</a>&gt;() * m2</div>
<div class="line">m3 -= s1 * m2.conjugate() * m1.adjoint().triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;() </div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Solving linear equations:<br  />
 \( M_2 := L_1^{-1} M_2 \) <br  />
 \( M_3 := {L_1^*}^{-1} M_3 \) <br  />
 \( M_4 := M_4 U_1^{-1} \) </td><td><br  />
 <div class="fragment"><div class="line">L1.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda">Eigen::UnitLower</a>&gt;().solveInPlace(M2)</div>
<div class="line">L1.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;().adjoint().solveInPlace(M3)</div>
<div class="line">U1.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a>&gt;().solveInPlace&lt;OnTheRight&gt;(M4)</div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda">Eigen::UnitLower</a></div><div class="ttdeci">@ UnitLower</div><div class="ttdef"><b>Definition:</b> Constants.h:219</div></div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a></div><div class="ttdeci">@ Upper</div><div class="ttdef"><b>Definition:</b> Constants.h:213</div></div>
</div><!-- fragment -->  </td></tr>
</table>
<h2><a class="anchor" id="QuickRef_SelfadjointMatrix"></a>
Symmetric/selfadjoint views</h2>
<p>Just as for triangular matrix, you can reference any triangular part of a square matrix to see it as a selfadjoint matrix and perform special and optimized operations. Again the opposite triangular part is never referenced and can be used to store other information.</p>
<dl class="section note"><dt>Note</dt><dd>The .selfadjointView() template member function requires the <code>template</code> keyword if it is used on an object of a type that depends on a template parameter; see <a class="el" href="TopicTemplateKeyword.html">The template and typename keywords in C++</a> for details.</dd></dl>
<table class="example">
<tr>
<th>Operation</th><th>Code </th></tr>
<tr>
<td>Conversion to a dense matrix: </td><td><div class="fragment"><div class="line">m2 = m.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;();</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td><a class="el" href="classEigen_1_1Product.html" title="Expression of the product of two arbitrary matrices or vectors.">Product</a> with another general matrix or vector: </td><td><div class="fragment"><div class="line">m3  = s1 * m1.conjugate().selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a>&gt;() * m3;</div>
<div class="line">m3 -= s1 * m3.adjoint() * m1.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;();</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Rank 1 and rank K update: <br  />
 \( upper(M_1) \mathrel{{+}{=}} s_1 M_2 M_2^* \) <br  />
 \( lower(M_1) \mathbin{{-}{=}} M_2^* M_2 \) </td><td><br  />
 <div class="fragment"><div class="line">M1.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a>&gt;().rankUpdate(M2,s1);</div>
<div class="line">M1.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;().rankUpdate(M2.adjoint(),-1); </div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Rank 2 update: ( \( M \mathrel{{+}{=}} s u v^* + s v u^* \)) </td><td><div class="fragment"><div class="line">M.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a>&gt;().rankUpdate(u,v,s);</div>
</div><!-- fragment -->  </td></tr>
<tr>
<td>Solving linear equations:<br  />
( \( M_2 := M_1^{-1} M_2 \)) </td><td><div class="fragment"><div class="line"><span class="comment">// via a standard Cholesky factorization</span></div>
<div class="line">m2 = m1.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a>&gt;().llt().solve(m2);</div>
<div class="line"><span class="comment">// via a Cholesky factorization with pivoting</span></div>
<div class="line">m2 = m1.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a>&gt;().ldlt().solve(m2);</div>
</div><!-- fragment -->  </td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:55 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
